package db_main

import (
	"fmt"
	string2 "longmen/server/pkg/common/helper/string"
	utils2 "longmen/server/pkg/common/helper/util"
	"longmen/server/pkg/db/mysql"
	"longmen/server/pkg/db/mysql/models/models_main"
)

func GetAnnouncementList(param map[string]interface{}, page int, size int) ([]*models_main.Announcement, error) {
	page = string2.GetDefaultNum(page, 1)
	size = string2.GetDefaultNum(size, 20)
	o := make([]*models_main.Announcement, 0)
	table := mysql.GetRTable(&models_main.Announcement{})
	mysql.Condition(table, param, "", "create_time DESC", page, size)
	err := table.Find(&o).Error
	if err != nil {
		err = fmt.Errorf("%s%s", utils2.Convert2(), err.Error())
	}
	return o, err
}
